package com.sky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sky.dto.PointPageQueryDTO;
import com.sky.entity.Medicinal;
import com.sky.entity.Point;
import com.sky.mapper.PointMapper;
import com.sky.result.PageResult;
import com.sky.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PointServiceImpl implements PointService {
    @Autowired
    private PointMapper pointMapper;
    @Override
    public List<Point> pointList() {
        List<Point> pointList = pointMapper.pointList();
        return pointList;
    }

    @Override
    public PageResult pageQuery(PointPageQueryDTO pointPageQueryDTO) {
        IPage iPage=new Page(pointPageQueryDTO.getPage(),pointPageQueryDTO.getPageSize());
        LambdaQueryWrapper<Point> lam=new LambdaQueryWrapper<>();
        pointMapper.selectPage(iPage,lam);
        long total=iPage.getTotal();
        List<Point> pointList=iPage.getRecords();
        PageResult pageResult=new PageResult(total,pointList);
        return pageResult;
    }

}
